import * as vscode from 'vscode';
import { USER_COMMANDS} from './command_names';

export const executeCommand = async (type: string): Promise<void> =>
  vscode.commands.executeCommand(await getCommandByType(type));


async function getCommandByType(type: string) : Promise<string> {
  if (type === 'json_format'){
    return USER_COMMANDS.JSON_FORMAT;
  }
  if (type === 'execute_this_request'){
    return USER_COMMANDS.DO_HTTP_REQUEST;
  }
  if (type === 'config_file'){
    return USER_COMMANDS.HTTP_REQUEST;
  }
  return '';
}
